import { FormSchema } from '/@/components/BasicForm/type/form';

export const fileSystemSizeSchema: FormSchema[] = [
  {
    field: 'availabilityZone',
    label: '可用区编码',
    component: 'Input',
    componentProps: {
      placeholder: '请输入可用区编码',
    },
    labelWidth: 100,
    colProps: { span: 24 },
  },
  {
    field: 'enterpriseProjectId',
    label: '企业项目ID',
    component: 'Input',
    componentProps: {
      placeholder: '请输入文件系统绑定的企业项目ID',
    },
    labelWidth: 100,
    colProps: { span: 24 },
  },
  {
    field: 'shareProto',
    label: '共享协议',
    component: 'Select',
    componentProps: {
      placeholder: '请选择共享协议',
      options: [
        {
          label: 'NFS',
          value: 'NFS',
        },
        {
          label: 'CIFS',
          value: 'CIFS',
        },
      ],
    },
    labelWidth: 100,
    colProps: { span: 24 },
  },
  {
    field: 'shareType',
    label: '文件系统类型',
    component: 'Select',
    componentProps: {
      placeholder: '请选择文件系统类型',
      options: [
        {
          label: '标准型',
          value: 'STANDARD',
        },
        {
          label: '性能型',
          value: 'PERFORMANCE',
        },
      ],
    },
    labelWidth: 100,
    colProps: { span: 24 },
  },

  {
    field: 'minSize',
    label: '容量最小值',
    component: 'InputNumber',
    componentProps: ({ formActionType }) => {
      return {
        placeholder: '请输入容量最小值',
        min: 500,
        max: 327680,
        addonAfter: 'GB',
        onChange: (e) => {
          const { updateSchema, setFieldsValue } = formActionType;
          setFieldsValue({ maxSize: undefined });
          updateSchema({
            field: 'maxSize',
            componentProps: {
              placeholder: '请输入容量最大值',
              min: e,
              max: 327680,
              addonAfter: 'GB',
            },
          });
        },
      };
    },
    labelWidth: 100,
    colProps: { span: 24 },
  },

  {
    field: 'maxSize',
    label: '容量最大值',
    component: 'InputNumber',
    componentProps: ({ formActionType }) => {
      return {
        placeholder: '请输入容量最大值',
        min: 500,
        max: 327680,
        addonAfter: 'GB',
        onChange: (e) => {
          const { updateSchema, setFieldsValue } = formActionType;
          setFieldsValue({ minSize: undefined });
          updateSchema({
            field: 'minSize',
            componentProps: {
              placeholder: '请输入容量最小值',
              min: 500,
              max: e,
              addonAfter: 'GB',
            },
          });
        },
      };
    },
    labelWidth: 100,
    colProps: { span: 24 },
  },
];

export const columns = [
  {
    title: '可用区编码',
    dataIndex: 'availabilityZone',
  },
  {
    title: '企业项目ID',
    dataIndex: 'enterpriseProjectId',
  },
  {
    title: '共享协议',
    dataIndex: 'shareProto',
  },
  {
    title: '文件系统类型',
    dataIndex: 'shareType',
  },
  {
    title: '容量最小值',
    dataIndex: 'minSize',
  },
  {
    title: '容量最大值',
    dataIndex: 'maxSize',
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: '200px',
  },
];
